package com.lwj.liwanjia.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.utils.MyListView;
import com.lwj.liwanjia.view.activity.dianpu.ShopDetailActivity;
import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;

import java.util.List;

/**
 * 所有商品分类
 */

public class ShopClassifyAdapter extends SuperBaseAdapter<String> {

    private Context context;
    private List<String> list;

    public ShopClassifyAdapter(Context context, List<String> data) {
        super(context, data);
        this.list = data;
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder holder, String item, int position) {
        MyListView myListView = holder.getView(R.id.mylist);
        ShopClassifyAdapter1 adapter1 = new ShopClassifyAdapter1(list, context);
        myListView.setAdapter(adapter1);
        myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(context, ShopDetailActivity.class);
                context.startActivity(intent);
            }
        });
    }

    @Override
    protected int getItemViewLayoutId(int position, String item) {
        return R.layout.shop_classify_item;
    }
}
